package com.lfg.leetcode.leetcode0;

public class No27RemoveElement {

    public static int removeElement(int[] nums, int val) {
        int j = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == val) {
                continue;
            }
            if (i != j) {
                nums[j] = nums[i];
            }
            j++;
        }
        return j;
    }

    public static void main(String[] args) {
        int l = removeElement(new int[]{1, 1, 2}, 2);
        System.out.println(l);
    }
}

